//
//  SearchViewController.m
//  MeiLiYiChu
//
//  Created by mac on 16/2/25.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "SearchViewController.h"
#import "XSSearchViewController.h"
@interface SearchViewController ()<UISearchBarDelegate>
{
    
    NSString * changeText;
}
@end

@implementation SearchViewController

-(void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBarHidden =YES;
    
}
-(void)viewDidDisappear:(BOOL)animated
{
    self.navigationController.navigationBarHidden =NO;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    UISearchBar * _search =[[UISearchBar alloc]initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, 40)];
    _search.delegate =self;
    _search.showsCancelButton =YES;
    
    _search.placeholder =@"请输入搜索名称";
    _search.text =@"";
    
    
    [self.view addSubview:_search];
}

-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
    changeText =searchText;
}
-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
    XSSearchViewController * searchVC =[[XSSearchViewController alloc]init];
    searchVC.Title =changeText;
    self.hidesBottomBarWhenPushed =YES;
    [self.navigationController pushViewController:searchVC animated:YES];
    self.hidesBottomBarWhenPushed =NO;

}
-(void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
